//
//  LZRecommendUserCell.m
//  LZHundredJie
//
//  Created by apple on 16/4/3.
//  Copyright © 2016年 m14a.cn. All rights reserved.
//

#import "LZRecommendUserCell.h"
#import "UIImageView+WebCache.h"
#import "LZRecommendUserItem.h"

@interface LZRecommendUserCell ()
/** 头像*/
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
/** 用户昵称*/
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
/** 关注人数*/
@property (weak, nonatomic) IBOutlet UILabel *countLabel;

@end

@implementation LZRecommendUserCell

- (void)awakeFromNib {
    
}

- (void)setItem:(LZRecommendUserItem *)item
{
    _item = item;
    // 1.设置图片
    // 头像
    UIImage *placeholder = [UIImage lz_circleImageNamed:@"defaultUserIcon"];
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:item.header] placeholderImage:placeholder completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
        if (image == nil) return ;
        // 获取圆形图片
        UIImage *newImage = [image circleImage];
        self.iconView.image = newImage;
    }];
    
    // 2.设置用户昵称
    self.nameLabel.text = item.screen_name;
    
    // 3.粉丝数量
    NSString *numStr = [NSString stringWithFormat:@"%zd人订阅", item.fans_count];
    
    // 转数字
    int num = [numStr intValue];
    if (num > 10000) {
        CGFloat numF = num / 10000.0;
        numStr = [NSString stringWithFormat:@"%.1f万人订阅", numF];
        numStr = [numStr stringByReplacingOccurrencesOfString:@".0" withString:@""];
    }
    
    // 3.关注人数
    self.countLabel.text = numStr;
}

- (void)setFrame:(CGRect)frame
{
    frame.size.height -= 2;
    [super setFrame:frame];
}

@end
